#include <stdio.h>
#include <string.h>

#include <utils/string.h>

char * st_lsub(const char * s, int step)
{
	static char lsub[32];

	register int i = 0;

	while (*s && i < step)
	{
		*(lsub+(i++)) = *s++;
		if (i == 31)
		{
			break;
		} 
	}

	*(lsub+i) = 0;

	return lsub;
}

int st_ipnport(const char * s, char * ip, unsigned short * port)
{
	int ret = 0;
	
	if (ip == NULL || port == NULL)
	{
		return -1;
	}

	ret = sscanf(s, "%[^:]:%hu", ip, port);
	if (ret != 2)
	{
		return -1;
	}

	return 0;
}
